home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / prntcb / printcb.frm < prev    next >
Text File  |  1995-05-08  |  6KB  |  222 lines

  1. VERSION 2.00
  2. Begin Form PrintCB 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Print Clipboard"
  5.    ClientHeight    =   4860
  6.    ClientLeft      =   1620
  7.    ClientTop       =   540
  8.    ClientWidth     =   5220
  9.    Height          =   5265
  10.    Icon            =   PRINTCB.FRX:0000
  11.    Left            =   1560
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   4860
  16.    ScaleWidth      =   5220
  17.    Top             =   195
  18.    Width           =   5340
  19.    Begin CommandButton CancelButton 
  20.       Caption         =   "&Cancel"
  21.       Height          =   390
  22.       Left            =   3240
  23.       TabIndex        =   4
  24.       Top             =   4320
  25.       Width           =   1170
  26.    End
  27.    Begin CommandButton PrintButton 
  28.       Caption         =   "&Print"
  29.       Height          =   390
  30.       Left            =   600
  31.       TabIndex        =   3
  32.       Top             =   4320
  33.       Visible         =   0   'False
  34.       Width           =   1170
  35.    End
  36.    Begin CheckBox TextOnly 
  37.       Caption         =   "Text Only"
  38.       FontBold        =   -1  'True
  39.       FontItalic      =   0   'False
  40.       FontName        =   "MS Sans Serif"
  41.       FontSize        =   12
  42.       FontStrikethru  =   0   'False
  43.       FontUnderline   =   0   'False
  44.       Height          =   375
  45.       Left            =   1080
  46.       TabIndex        =   8
  47.       Top             =   3480
  48.       Width           =   3015
  49.    End
  50.    Begin CheckBox PromptBeforePrint 
  51.       Caption         =   "Prompt Before Printing"
  52.       FontBold        =   -1  'True
  53.       FontItalic      =   0   'False
  54.       FontName        =   "MS Sans Serif"
  55.       FontSize        =   12
  56.       FontStrikethru  =   0   'False
  57.       FontUnderline   =   0   'False
  58.       Height          =   390
  59.       Left            =   1080
  60.       TabIndex        =   5
  61.       Top             =   3000
  62.       Value           =   1  'Checked
  63.       Width           =   2985
  64.    End
  65.    Begin Label Message 
  66.       BackColor       =   &H00FFFF00&
  67.       FontBold        =   -1  'True
  68.       FontItalic      =   0   'False
  69.       FontName        =   "MS Sans Serif"
  70.       FontSize        =   9.75
  71.       FontStrikethru  =   0   'False
  72.       FontUnderline   =   0   'False
  73.       Height          =   300
  74.       Left            =   600
  75.       TabIndex        =   6
  76.       Top             =   3960
  77.       Width           =   3855
  78.    End
  79.    Begin Label Explination 
  80.       Caption         =   " To Print the clipboard just PASTE something to the clipboard and then DOUBLE-CLICK the ICON "
  81.       Height          =   588
  82.       Index           =   2
  83.       Left            =   96
  84.       TabIndex        =   2
  85.       Top             =   2400
  86.       Width           =   5004
  87.    End
  88.    Begin Label Explination 
  89.       Caption         =   "To print the clipboard without first being prompted just turn off the 'Prompt before Print' checkbox.  IF you then want to return to this configuration screen just 'Double click' the ICON with NOTHING in the Clipboard.  "
  90.       Height          =   972
  91.       Index           =   1
  92.       Left            =   96
  93.       TabIndex        =   1
  94.       Top             =   1248
  95.       Width           =   5004
  96.    End
  97.    Begin Label Explination 
  98.       Caption         =   "   1)TEXT  2)BITMAP  3)D.I.B."
  99.       Height          =   300
  100.       Index           =   3
  101.       Left            =   96
  102.       TabIndex        =   7
  103.       Top             =   768
  104.       Width           =   5004
  105.    End
  106.    Begin Label Explination 
  107.       Caption         =   "This utility will print the contents of the Windows clipboard.  It can print Three types of data from the clipboard: "
  108.       Height          =   588
  109.       Index           =   0
  110.       Left            =   96
  111.       TabIndex        =   0
  112.       Top             =   96
  113.       Width           =   5004
  114.    End
  115. End
  116.  
  117. Sub CancelButton_Click ()
  118.  
  119. PrintCB.Windowstate = WS_MINIMIZED
  120.  
  121. End Sub
  122.  
  123. Sub Form_Load ()
  124.   
  125. PrintCB.Windowstate = WS_MINIMIZED
  126. OKtoPrint = False
  127.  
  128. End Sub
  129.  
  130. Sub Form_Resize ()
  131.  
  132. Dim TextToPrint$
  133.  
  134. If PrintCB.Windowstate = WS_NORMAL Then
  135.   If PrintCB.PromptBeforePrint.value = False Then
  136.     rc = Printit()
  137.     If rc = 0 Then
  138.       PrintCB.Windowstate = WS_MINIMIZED
  139.     End If
  140.   Else
  141.     CBType = GetClipboardType()
  142.     If CBType Then
  143.       PrintCB.PrintButton.visible = True
  144.       PrintCB.Message.caption = " OK to Print: " + TypeDescription + "?"
  145.     Else
  146.       PrintCB.PrintButton.visible = False
  147.       PrintCB.Message.caption = " No valid data in Clipboard!"
  148.     End If
  149.   End If
  150. End If
  151.  
  152. End Sub
  153.  
  154. Function GetClipboardType () As Integer
  155.   
  156. If Clipboard.GetFormat(CF_DIB) And TextOnly.value = False Then
  157.   GetClipboardType = CF_DIB
  158.   TypeDescription = "D.I.B"
  159. ElseIf Clipboard.GetFormat(CF_BITMAP) And TextOnly.value = False Then
  160.   GetClipboardType = CF_BITMAP
  161.   TypeDescription = "Bitmap"
  162. ElseIf Clipboard.GetFormat(CF_TEXT) Then
  163.   GetClipboardType = CF_TEXT
  164.   TypeDescription = "Text"
  165. Else
  166.   GetClipboardType = 0
  167. End If
  168.  
  169. End Function
  170.  
  171. Sub PrintButton_Click ()
  172.  
  173. a = b
  174. rc = Printit()
  175.  
  176. End Sub
  177.  
  178. Function Printit () As Integer
  179. '0 = OK
  180. '1 = Error
  181.  
  182. Printit = 0
  183. On Error GoTo Printit_Error
  184. CBType = GetClipboardType()
  185. Select Case CBType
  186.   Case CF_TEXT
  187.     TextToPrint$ = Clipboard.GetText(CF_TEXT)
  188.     Printer.Print TextToPrint$
  189.     Printer.EndDoc
  190.     PrintCB.Windowstate = WS_MINIMIZED
  191.   Case CF_BITMAP
  192.     PrintPIC.Show
  193.     PrintPIC.Windowstate = WS_MAXIMIZED
  194.     PrintPIC.Picture = Clipboard.GetData(CF_BITMAP)
  195.     PrintPIC.PrintForm
  196.     Printer.EndDoc
  197.     Unload PrintPIC
  198.     PrintCB.Windowstate = WS_MINIMIZED
  199.   Case CF_DIB
  200.     PrintPIC.Windowstate = WS_MAXIMIZED
  201.     PrintPIC.Picture = Clipboard.GetData(CF_DIB)
  202.     PrintPIC.PrintForm
  203.     Printer.EndDoc
  204.     Unload PrintPIC
  205.     PrintCB.Windowstate = WS_MINIMIZED
  206.   Case Else
  207.     Printit = 1
  208.     PrintCB.Message.caption = "No valid data in clipboard"
  209.     PrintCB.PrintButton.visible = False
  210. End Select
  211. Exit Function
  212.  
  213. Printit_Error:
  214. Debug.Print Str$(Err), Error$(Err)
  215. Printit = 1
  216. PrintCB.Message.caption = "An Error occured during print"
  217. PrintCB.PrintButton.visible = False
  218. Exit Function
  219.  
  220. End Function
  221.  
  222.